package com.google.android.material.internal;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.Checkable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.core.view.ViewCompat;
import o.ah.c;
import o.hc;
import o.in;

@RestrictTo({d.LIBRARY_GROUP})
public class CheckableImageButton extends AppCompatImageButton implements Checkable {
    private static final int[] ˊ = new int[]{16842912};
    private boolean ˎ;

    public CheckableImageButton(Context context) {
        this(context, null);
    }

    public CheckableImageButton(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c.ˊˋ);
    }

    public CheckableImageButton(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ViewCompat.ˏ(this, new hc(this) {
            final /* synthetic */ CheckableImageButton ˏ;

            {
                this.ˏ = r1;
            }

            public void ˎ(View view, AccessibilityEvent accessibilityEvent) {
                super.ˎ(view, accessibilityEvent);
                accessibilityEvent.setChecked(this.ˏ.isChecked());
            }

            public void ˋ(View view, in inVar) {
                super.ˋ(view, inVar);
                inVar.ˏ(true);
                inVar.ˎ(this.ˏ.isChecked());
            }
        });
    }

    public void setChecked(boolean z) {
        if (this.ˎ != z) {
            this.ˎ = z;
            refreshDrawableState();
            sendAccessibilityEvent(2048);
        }
    }

    public boolean isChecked() {
        return this.ˎ;
    }

    public void toggle() {
        setChecked(!this.ˎ);
    }

    public int[] onCreateDrawableState(int i) {
        if (this.ˎ) {
            return mergeDrawableStates(super.onCreateDrawableState(ˊ.length + i), ˊ);
        }
        return super.onCreateDrawableState(i);
    }
}
